﻿using System;
using System.Data;
using System.Configuration;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using Talentnet.Core.Web;
using Talentnet.Core.Utilities.Cryptophy;
using Talentnet.Data;
using Talentnet.Data.Factory;
using Talentnet.Core.Utilities;
using Telerik.Web.UI;

/// <summary>
/// Summary description for NormalPage
/// </summary>
public class NormalPage : SecurePage, SecurePage.ICustomLoadText
{
    public NormalPage()
    {
        //
        // TODO: Add constructor logic here
        //
    }
    public ILoginUser DBUser
    {
        get
        {
            return LoginUserFactory.CreateInstance();
        }
    }
    protected override void DoPagePreInit()
    {
        this.Theme = "TLN";
    }

    protected override void PageInitialize()
    {
        
    }
    protected override void OnLoad(EventArgs e)
    {
        if (SessionManager.PwdExpired && Request.RawUrl.ToLower().IndexOf("resetpwd.aspx") == -1)
        {
            Response.Redirect("~/resetPwd.aspx");
        }
        base.OnLoad(e);
    }
    public override ICryptor Cryptor
    {
        get { return CryptoAgent.Current; }
    }
    protected override void DoIntruderDetected(IntruderType type)
    {

        switch (type)
        {
            case IntruderType.Permission:
                Response.Redirect("~/FreeAccess/404.htm");
                break;
        }
    }
    protected override void OnAspxWriteLog()
    {

    }

    protected override void OnIntruderWriteLog()
    {


    }

    public void OnLoadText(Control ctrl, TextResourceLoader res)
    {
        if (ctrl is RadGrid)
        {

            RadGrid grid = ((RadGrid)ctrl);
            foreach (GridColumn col in grid.Columns)
            {
                col.HeaderText = res.GetText(grid.ID + "_" + col.UniqueName);
            }
        }
    }
}
